<script>
import {http} from "@/api";

export default {
  name: "index",
  data() {
    return {
      ruleForm: {
        logo: '',
        header_bg: '',
        header_title: '',
        ad_url: '',
        buse_html: ''
      }
    }
  },
  created() {
    http.config.list().then(res => {
      if (res.data.length) {
        this.ruleForm = res.data[0]
      }
    })
  },
  methods: {
    save() {
      http.config.create(undefined,this.ruleForm).then(res => {
        this.$message.success('保存成功')
      })
    }
  }
}
</script>

<template>
  <div style="background-color: #ffffff;">
    <div style="padding-top: 120px;margin: 0 auto;width: 500px">
      <el-form label-position="top">
        <el-form-item label="标题">
          <el-input v-model="ruleForm.header_title" />
        </el-form-item>
        <el-form-item label="logo">
          <FileUpload v-model="ruleForm.logo" />
        </el-form-item>
        <el-form-item label="顶部背景图">
          <FileUpload v-model="ruleForm.header_bg" />
        </el-form-item>
        <el-form-item label="广告轮播">
          <FileUpload v-model="ruleForm.ad_url" multiple/>
        </el-form-item>
        <el-form-item label="核心优势">
          <RichEditor v-model="ruleForm.buse_html" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="save">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<style scoped lang="scss">

</style>
